"""
插件基类定义
"""
from abc import ABC, abstractmethod
from typing import Any, Dict, Optional


class BasePlugin(ABC):
    """插件基类，所有插件必须继承此类"""

    def __init__(self, plugin_id: str, config: Dict[str, Any] = None):
        """
        初始化插件

        Args:
            plugin_id: 插件唯一标识
            config: 插件配置参数
        """
        self.plugin_id = plugin_id
        self.config = config or {}

    @abstractmethod
    def execute(self, input_data: Any) -> Any:
        """
        执行插件逻辑

        Args:
            input_ 输入数据

        Returns:
            处理后的数据
        """
        pass

    def validate_config(self) -> bool:
        """
        验证插件配置是否有效

        Returns:
            配置是否有效
        """
        return True

    def get_metadata(self) -> Dict[str, Any]:
        """
        获取插件元数据

        Returns:
            插件元数据
        """
        return {
            "plugin_id": self.plugin_id,
            "plugin_type": self.__class__.__name__,
            "config": self.config
        }